package org.hxzon.demo.nio;

import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;

public class CmdHeader {
	public static final int Fail=0;
	public static final int Ok=1;
	public static final int RequestDownload=2;
	public static final int RequestEcho=3;
	
	public int seq;
	public int cmd;
	public int rev;
	public int len;
	public ByteBuffer buffer;
	
	public CmdHeader(ByteBuffer buffer){
		this.buffer=buffer;
		try{
			seq=buffer.getInt();
			cmd=buffer.getInt();
			rev=buffer.getInt();
			len=buffer.getInt();
		}catch(BufferUnderflowException e){
		}
	}
	
	public static CmdHeader parse(ByteBuffer buffer){
		return new CmdHeader(buffer);
	}
}
